import React, { useEffect } from 'react';
import Router from './router';
import './App.css'
import { useAppSelector } from './app/hooks';
import { useLocation, useNavigate } from 'react-router-dom';
const App = () => {
  const isLogin = useAppSelector(state => state.user.isLogin)
  const { pathname } = useLocation()
  const navigate = useNavigate()
  useEffect(() => {
    if(!isLogin && pathname !== '/login') {
      navigate('/login')
    }
  }, [isLogin])

  return <Router></Router>
}

export default App